import { queryAllSystemLog } from '../services/system';

export default {
  namespace: 'systemlog',

  state: {
    resdata: {
      list: [],
      pagination: {},
    },
    loading: {
      reslist:true,
    },
  },

  effects: {
    *fetch_systemlog_list({ payload }, { call, put }) {
      yield put({
        type: 'changeLoading',
        payload:{reslist:true}
      })
      const response =yield call(queryAllSystemLog, payload);
      response &&  (
        yield put({
          type: 'appendData',
          payload:response.data,
        })
      )
      yield put({
        type: 'changeLoading',
        payload:{reslist:false}
      })
    },




  },

  reducers: {
    appendData(state, action) {
      return {
        ...state,
        resdata: action.payload,
      };
    },
    changeLoading(state, action) {
      return {
        ...state,
        loading: {
          ...state.loading,
          ...action.payload,
        },
      };
    },
    appendClearState(state, action) {
      return {
        ...state,
        resdata:{},
        loading:{}
      };
    },
  },
};

